# 导入redis数据库模块，用来redis创建数据库对象
from redis import StrictRedis
# 导入日志模块，用来设置日志等级
import logging


class Config:
    DEBUG = None

    # mysql数据库连接地址
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@localhost/info19"
    # 设置数据库跟踪
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 由于需要设置session信息，因此需要设置secret_key
    SECRET_KEY = "wpSMNLRHGucW2E11KswiNZsLOokX8MWslPVBR1SIHxZVcnydID12bw=="

    # 定义redis数据库的存储信息
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379
    # 设置session存储的位置
    SESSION_TYPE = "redis"
    # 设置session签名
    SESSION_USE_SIGNER = True
    # 生成存储session信息的redis对象
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    # 设置session的过期时间
    PREMANENT_SESSION_LIFETIME = 86400
    # 设置日志等级
    level_name = logging.DEBUG


class ProductionConfig(Config):
    level_name = logging.ERROR
    DEBUG = False


class DevelopmentConfig(Config):
    DEBUG = True


config = {
    "production": ProductionConfig,
    "development": DevelopmentConfig
}
